package com.qiku.controller;


import com.qiku.domin.Course;
import com.qiku.domin.CourseVO;
import com.qiku.domin.ResponseResult;
import com.qiku.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    @RequestMapping(value = "/findCourseByCondition", method = RequestMethod.POST)
    public ResponseResult findCourseByCondition(@RequestBody CourseVO courseVO) {
        // 查询课程
        List<Course> courseList = courseService.findCourseByCondition(courseVO);
        // 封装结果集
        ResponseResult result = null;
        if (null != courseList) {
            result = new ResponseResult(true, 200, "响应成功", courseList);
        } else {
            result = new ResponseResult(false, 200, "查询结果为空", courseList);
        }
        return result;
    }



}
